package com.beans.usercontoller;

import com.beans.userservice.UserService;
import com.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;


@Controller
public class UserController2 {
    private UserService userService;
    //2.构造方法注入
    @Autowired
    public UserController2(UserService userService){
        this.userService=userService;
    }


    public void sayHi(String name){
        System.out.println("Hi "+name);
    }
    public User getUserId(Integer id){
        //伪代码
        return userService.getUserById(id);
    }
}
